package com.jdls.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 嘉德罗斯
 * @date 2021/9/12
 */
@Configuration
public class DruidConfig {
    @Value("${jdbc.ClassName}")
    private String ClassName;
    @Value("${jdbc.url}")
    private String url;
    @Value("${jdbc.username}")
    private String username;
    @Value("${jdbc.password}")
    private String password;
    @Bean("druid")
    public DruidDataSource getDateSource(){
        DruidDataSource ds = new DruidDataSource();
        ds.setDriverClassName(ClassName);
        ds.setUrl(url);
        ds.setUsername(username);
        ds.setPassword(password);
        System.out.println(url);
        return ds;
    }
}
